<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	// 获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量 
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	// 将 "项目路径basePath" 放入pageContext中，待以后用EL表达式读出。 
	pageContext.setAttribute("basePath", basePath);
	//out.write(basePath);
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<title></title>



<!-- Bootstrap core CSS -->
<link href="<%=basePath %>bootstrap/css/bootstrap.min.css" rel="stylesheet">


<!-- Optional Bootstrap Theme -->
<link href="data:text/css;charset=utf-8,"
	data-href="<%=basePath %>bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"
	id="bs-theme-stylesheet">

<!-- Documentation extras -->
<link href="<%=basePath %>/bootstrap/css/docs.min.css" rel="stylesheet">
<!--[if lt IE 9]><script src="../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="./../bootstrap/js/ie-emulation-modes-warning.js"></script>

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
  <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<!-- Favicons -->

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="<%=basePath %>bootstrap/js/jquery.min.js"></script>


<script src="<%=basePath %>bootstrap/js/bootstrap.min.js"></script>



<script src="<%=basePath %>bootstrap/js/docs.min.js"></script>




<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="<%=basePath %>bootstrap/js/ie10-viewport-bug-workaround.js"></script>


<script type="text/javascript">
	function tranInfo() {
		var stuGrade = "";
		var stuAmount = $("#stuAmount")[0].value;
		for (var i = 0; i < stuAmount; i++) {
			stuGrade += $("#"+i)[0].value + ":";
			console.info($("#"+i)[0].value);
		}
		$("#allStuGrade")[0].value = stuGrade+"0";
	}

	function putIn() {
		var put = $("#allStuGrade")[0].value;
		if (put != null && put != "") {
			return true;
		} else {
			return false;
		}
	}
</script>

<!-- <script src="http://code.jquery.com/jquery-1.12.4.js" ></script> -->


</head>
<body>
      <hr>
      <form action="<%=basePath%>StudentGradeSevelet" method="post">
	<input type="hidden" name="atsc" value="1">      
      <div class="row">
      <div class="col-md-3" align="center"><font size="4">请选择课程：</font></div>
      <div class="col-md-3"><select class="form-control " name="tc">
      <c:forEach items="${sessionScope.allTC }" var="atc">
      <option>${atc.coursename}</option>
      </c:forEach>
       </select></div>
      <div class="col-sm-offset-2 col-md-2" >
      <button type="submit" class="btn btn-default">&nbsp;查&nbsp;&nbsp;&nbsp;询&nbsp;</button>
      </div>
      </div>
      </form>
      <hr>
      
	<input type="hidden" id="stuAmount" value="${sessionScope.stuAllScore }">
	<table class="table table-striped">
		<thead>
			<tr>
				<th>#</th>
				<th>学生姓名</th>
				<th>课程编号</th>
				<th>课程名称</th>
				<th>学生成绩</th>
				<th>输入学生成绩</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${sessionScope.GiveGrade}" var="stu" varStatus="st">
				<tr>
					<td>${st.index+1}</td>
					<td>${stu.username}</td>
					<td>${stu.courseid}</td>
					<td>${stu.coursename}</td>
					<td>${stu.coursescore}</td>
					<td><div class="col-md-4">
							<input type="text" class="form-control" id="${st.index}"
								placeholder="成绩">
						</div></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>



	<form action="<%=basePath%>StudentGradeSevelet" method="post">
		<input type="hidden" name="atsc" value="2"> 
		<input type="hidden" id="allStuGrade" name="allStuGrade" value="">
		<div class="row">
			<div class="col-sm-offset-3 col-md-3">
				<button type="button" class="btn btn-default" onclick="tranInfo();">&nbsp;上&nbsp;&nbsp;&nbsp;传&nbsp;</button>
			</div>
			<div class="col-sm-offset-1 col-md-5">
				<button type="submit" class="btn btn-default"
					onclick="return putIn();">&nbsp;提&nbsp;&nbsp;&nbsp;交&nbsp;</button>
			</div>
		</div>
	</form>
</body>
</html>
